package com.dr.springboot.starter.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

//todo filter 创建一个filter，在doFilter中做相应的过滤，这里获取到的是servlet对象
@Slf4j
@Component
@WebFilter(urlPatterns = "/filter/*",filterName = "loginFilter")
public class LoginFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("init filter");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("do filter");
    }

    @Override
    public void destroy() {
        log.info("destroy filter");
    }
}
